# 优先队列实现
class PriorityQueue:
    def __init__(self, cpr):
        self.queue = []
        self.cpr = cpr

    def swap(self, a, b):
        self.queue[a], self.queue[b] = self.queue[b], self.queue[a]

    def swim(self):
        c = len(self.queue) - 1

        while c >= 1:
            f = int((c - 1) / 2)

            if self.cpr(self.queue[c], self.queue[f]) > 0:
                self.swap(c, f)
            else:
                break

    def push(self, val):
        self.queue.append(val)
        self.swim()

    def sink(self):
        f = 0

        while True:
            c1 = 2 * f + 1
            c2 = c1 + 1

            c = None
            val1 = self.queue[c1] if c1 < len(self.queue) else None
            val2 = self.queue[c2] if c2 < len(self.queue) else None

            if val1 is not None and val2 is not None:
                c = c1 if self.cpr(val1, val2) > 0 else c2
            elif val1 is not None and val2 is None:
                c = c1
            elif val1 is None and val2 is not None:
                c = c2
            else:
                break

            if self.cpr(self.queue[c], self.queue[f]) > 0:
                self.swap(c, f)
                f = c
            else:
                break

    def shift(self):
        self.swap(0, len(self.queue) - 1)
        res = self.queue.pop()
        self.sink()
        return res

    def peek(self):
        return self.queue[0]

    def size(self):
        return len(self.queue)


# 输入获取
taskNum = int(input())

ranges = []
for i in range(taskNum):
    ranges.append(list(map(int, input().split())))


# 算法入口
def getResult(ranges):
    ranges.sort(key=lambda x: x[0])
    end = PriorityQueue(lambda a, b: b[0] - a[0])
    maxV = 0
    sum = 0

    for ran in ranges:
        s, e, p = ran

        while end.size() > 0:
            top = end.peek()

            if top[0] < s:
                poll = end.shift()
                sum -= poll[1]
            else:
                break

        end.push((e, p))
        sum += p

        if sum > maxV:
            maxV = sum

    return maxV


print(getResult(ranges))